﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class shuangseze : System.Web.UI.Page
{
    protected List<Model.LotteryAnnouncement> arlist = null;
    protected string[] SSQList = null;
    protected string SSQblue = null;
    protected int jinqiCount = 0;

    protected DataTable dtPaperList = new DataTable();  //尾数汇总 
    protected void Page_Load(object sender, EventArgs e)
    {
        ZoushiManage.FangWenZouShi();
        if (!IsPostBack)
        {
            jinqiCount = 30;
            bindData(30);
        }
    }

    protected void bindData(int maxValue)
    {

        int Count = 0;
        arlist = BLL.LotteryAnnouncement.GetPageList_Where(0, maxValue, 1, out Count);

        if (arlist != null)
        {
            dtPaperList.Columns.Add("Hezhi0", typeof(string));
            dtPaperList.Columns.Add("Hezhi1", typeof(string));
            dtPaperList.Columns.Add("Hezhi2", typeof(string));
            dtPaperList.Columns.Add("Hezhi3", typeof(string));
            dtPaperList.Columns.Add("Hezhi4", typeof(string));
            dtPaperList.Columns.Add("Hezhi5", typeof(string));
            dtPaperList.Columns.Add("Hezhi6", typeof(string));
            dtPaperList.Columns.Add("Hezhi7", typeof(string));
            dtPaperList.Columns.Add("Hezhi8", typeof(string));
            dtPaperList.Columns.Add("Hezhi9", typeof(string));
            for (int i = 0; i < arlist.Count; i++)
            {
                //重号
                string[] redBall = arlist[i].LotteryNo.Split('+')[0].Split(',');
                for (int m = 0; m < redBall.Length; m++)
                {
                    //计算条形图中每个数的个数红球
                    bindTiaoxing(int.Parse(redBall[m]));
                }

                bindWs(redBall); 
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        jinqiCount = int.Parse(DropDownList1.SelectedValue);
        bindData(int.Parse(DropDownList1.SelectedValue));
    }
    /// <summary>
    /// 计算尾数
    /// </summary>
    /// <param name="data">对应红球的号码</param>
    protected void bindWs(string[] redBall)
    {

        DataRow newRow = dtPaperList.NewRow();
        for (int m = 0; m < redBall.Length; m++)
        {
            int data = int.Parse(redBall[m].Substring(redBall[m].Length - 1, 1));
            for (int i = 0; i < 10; i++)
            {
                if (data == i)
                {
                    string aa = newRow["Hezhi" + i].ToString();
                    if (aa == "")
                    {
                        newRow["Hezhi" + i] ="0";
                    }
                   int a =  int.Parse(newRow["Hezhi" + i].ToString());

                   newRow["Hezhi" + i] = (a + 1).ToString();
                    
                }
            }
        }
        dtPaperList.Rows.Add(newRow);
    }
    /// <summary>
    /// 计算红篮球的出现个数
    /// </summary>
    /// <param name="type">0 红球 1 蓝球</param>
    /// <param name="data">对应球的号码</param>
    protected int[] TiaoxingDT = new int[33];
    protected void bindTiaoxing(int data)
    {
        for (int i = 0; i < 33; i++)
        {
            if (data == (i + 1 ))
            {
                TiaoxingDT[i] += 1;
            }
        }
    }
}